<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
	<style type="text/css">
		*{
			margin: 0;
			padding: 0;
		}
		body{
			background: #ccc;
			height: 1000px;
		}
		.main{
			width: 500px;
			height: 300px;
			background: #eee;
			margin: 100px auto;
		}
		.box{
			width: 200px;
			height: 200px;
			background: orange;
		}
	</style>
</head>
<body>
	<div class="main">
		<div class="box">
			
		</div>
	</div>
	<script type="text/javascript">
		let box = document.querySelector('.box')
		
		box.onclick = function(ev){
			//clientX clientY 点击的位置距离当前body可是区域的距离
			// console.log(ev.clientX, ev.clientY)

			//pageX pageY 点击的距离对于整个页面来说，包含滚动条折叠部分
			// console.log(ev.pageX, ev.pageY)

			//screenX screenY 点击的位置距离电脑屏幕的距离
			// console.log(ev.screenX, ev.screenY)

			//offsetX offsetY 对于触发元素的左边上边的距离
			console.log(ev.offsetX, ev.offsetY)
		}
	</script>
</body>
</html>